package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

/**
 * 老人用餐计划
 *
 * @author ytche
 * @date 2017年8月30日
 *
 */
@Entity
@Table(name = "tnb_customer_food_plan")
@JsonApiResource(type = "cutomerFoodPlan")
public class CustomerFoodPlan extends BaseEntity {
	private static final long serialVersionUID = 1L;
	private Integer diningDate;// 用餐日期
	private Dicttype diningTime;// 用餐时间
	private Customer customer;// 老人
	private Set<Food> foods;
	private Employee createEmployee;// 记录人
	private User createUser;// 创建人

	@Column(name = "dining_date")
	public Integer getDiningDate() {
		return diningDate;
	}

	public void setDiningDate(Integer diningDate) {
		this.diningDate = diningDate;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "dinging_time_id")
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public Dicttype getDiningTime() {
		return diningTime;
	}

	public void setDiningTime(Dicttype diningTime) {
		this.diningTime = diningTime;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "customer_id")
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinTable(name = "rel_food_plan", joinColumns = { @JoinColumn(name = "plan_id") }, inverseJoinColumns = { @JoinColumn(name = "food_id") })
	@Fetch(FetchMode.JOIN)
	@JsonApiToMany
	@JsonApiIncludeByDefault
	public Set<Food> getFoods() {
		return foods;
	}

	public void setFoods(Set<Food> foods) {
		this.foods = foods;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "create_employee_id")
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public Employee getCreateEmployee() {
		return createEmployee;
	}

	public void setCreateEmployee(Employee createEmployee) {
		this.createEmployee = createEmployee;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "create_user_id")
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}
}
